package org.egomsl.mw.mapreduce;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;

public abstract class ABaseMapredTestBase {
    protected MiniDFSCluster dfsCluster;
    protected FileSystem fs;

    @Before
    public void setup() throws IOException, InterruptedException {
        Configuration conf = new Configuration();
        if (System.getProperty("test.build.data") == null) {
            System.setProperty("test.build.data", "/tmp/abase");
        }

        dfsCluster = new MiniDFSCluster(conf, 1, true, null);
        fs = dfsCluster.getFileSystem();
    }

    @After
    public void shutdown() {
        if(dfsCluster != null) dfsCluster.shutdown();
    }
}
